package com.zx.erp.market.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zx.erp.market.bean.Orderdetails;
import com.zx.erp.market.mapper.OrderdetailsMapper;
import com.zx.erp.market.service.OrderdetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderdetailsBizImpl implements OrderdetailsService {
    @Autowired
    private OrderdetailsMapper oddao;



    @Override
    public List<Orderdetails> findByOrderId(String orderid) {
        return oddao.selectByOrderId(orderid);
    }



    @Override
    public boolean addOrderDs(List<Orderdetails> orderdetails) {
        boolean flag = false;
        try {
            for (Orderdetails od : orderdetails) {
                flag = oddao.insertSelective(od);
                if (!flag){
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            flag=false;
        }
        return flag;
    }

    @Override
    public PageInfo<Orderdetails> findAllFZ(Integer customid,Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<Orderdetails> pageInfo = new PageInfo<>(oddao.selectAllFZ(customid));
        return pageInfo;
    }
}
